

//
//  NProjectShenbaoViewController.m
//  nncloud
//
//  Created by macfai on 2018/11/19.
//  Copyright © 2018 macfai. All rights reserved.
//

#import "NProjectShenbaoViewController.h"
#import "NShenbaoTypeViewController.h"
#import "NMyShenbaoViewController.h"

@interface NProjectShenbaoViewController ()<ZJScrollPageViewDelegate>

/**
 页面分栏的标题
 */
@property (strong,nonatomic) NSArray<NSString *>*titles;

/**
 横向分页滑动组件
 */
@property (strong,nonatomic) ZJScrollPageView *scrollPageView;

@end

@implementation NProjectShenbaoViewController
#define kSegmentHeight 45
- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = kWhiteColor;
    [self.navigationItem setItemWithTitle:@"项目申报" textColor:kNavigationTitleColor fontSize:18 itemType:center];
    
    ZJSegmentStyle *style = [[ZJSegmentStyle alloc] init];
    //显示滚动条
    style.showLine = false;
    // 颜色渐变
    style.gradualChangeTitleColor = YES;
    style.scrollTitle = NO;
    style.scrollLineColor = NColorFrom16RGB(0x23b7e5);
    style.selectedTitleColor = NColorFrom16RGB(0x23b7e5);
    style.segmentViewBounces = YES;
    style.titleFont = kFont15;
    style.adjustCoverOrLineWidth = YES;
    style.autoAdjustTitlesWidth = NO;
    style.segmentHeight = kSegmentHeight;
    self.titles = @[@"项目申报类型",
                    @"已申报项目",
                    ];
    // 初始化
    _scrollPageView = [[ZJScrollPageView alloc] initWithFrame:CGRectMake(0, 10, ScreenWidth, ScreenHeight - 20.0) segmentStyle:style titles:self.titles parentViewController:self delegate:self];
    [self.view addSubview:_scrollPageView];
    self.view.backgroundColor = kWhiteColor;
    
    
    UIView *line = [[UIView alloc]initWithFrame:CGRectMake(5, 55, ScreenWidth-10, 0.2)];
    line.backgroundColor = kLightGrayColor;
    [self.view addSubview:line];

}



#pragma mark ZJPhotoScrollViewDelegate
- (NSInteger)numberOfChildViewControllers {
    return self.titles.count;
}

- (UIViewController<ZJScrollPageViewChildVcDelegate> *)childViewController:(UIViewController<ZJScrollPageViewChildVcDelegate> *)reuseViewController forIndex:(NSInteger)index {
    
    UIViewController<ZJScrollPageViewChildVcDelegate> *childVc = reuseViewController;
    
    if (!childVc) {
        if (index%2==0) {
            childVc = [[NShenbaoTypeViewController alloc] init];
//            NShenbaoTypeViewController *vc = (NShenbaoTypeViewController *)childVc;
        } else {
            childVc = [[NMyShenbaoViewController alloc] init];
//            NMyShenbaoViewController *vc = (NMyShenbaoViewController *)childVc;
        }
    }
    return childVc;
}

- (BOOL)shouldAutomaticallyForwardAppearanceMethods{
    return NO;
}



@end
